package com.txtreader;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class MainActivity extends Activity {

	private final Activity activity = this;
	
	private Button btn_open;
	private ListView listView;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		
		listView = (ListView) findViewById(R.id.listView);
		btn_open = (Button) findViewById(R.id.btn_open);
		
		btn_open.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent intent = new Intent(activity, SDFileActivity.class);
				startActivity(intent);
				finish();
			}
		});
	}

	long l = 0;
	@Override
	public void onBackPressed() {
		super.onBackPressed();
		if ((System.currentTimeMillis() - l) > 2000) {
			Toast.makeText(getApplicationContext(), "再按一次退出程序",
					Toast.LENGTH_SHORT).show();
			l = System.currentTimeMillis();
		} else {
			finish();
		}
	}
	
}
